package com.diy.sigmund.diyorder.common.middleware.mq.rocketmq.spring.one;

import org.apache.rocketmq.spring.annotation.MessageModel;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

/**
 * <br>广播消息
 * <br>实现RocketMQListener接口
 * <br>申明泛型对象即业务对象
 * <br>使用@RocketMQMessageListener注解
 * <br>配置@RocketMQMessageListener注
 * <br>必须配置项入下
 * <br>group
 * <br>topic
 * <br>messageModel 设为 MessageModel.BROADCASTING
 * <br>使用@Component注解或者子注解
 * <br>实现接口方法
 *
 * @author ylm-sigmund
 * @since 2022/5/5 22:24
 */
@Component
@RocketMQMessageListener(
        topic = "${topic.broadcastConsumer}",
        consumerGroup = "${group.consumer.broadcastConsumer}",
        messageModel = MessageModel.BROADCASTING)
public class FirstBroadcastConsumer implements RocketMQListener<Object> {

    private static final Logger log = LoggerFactory.getLogger(FirstBroadcastConsumer.class);

    @Override
    public void onMessage(Object message) {
        log.info(String.format("FirstBroadcastConsumer name is %s data is %s", this.getClass().getSimpleName(),
                message));
    }

}
